/**
 * 给定一堆数，修改最少的数量令其值为1到N
 * 做一个标记即可。枚举。
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

template <typename T>
const T & mymax(const T & a, const T & b){
    return max(a, b);
}

template<typename T, typename ... Args>
const T & mymax(const T & t, const Args & ... args){
    return max(t, mymax(args ...));
}

template<typename T>
void input(vector<T> & v, int n){
	v.assign(n + 1, {});
    for(int i=1;i<=n;++i) cin >> v[i];
	return;
}

template<typename T>
istream & operator >> (istream & is, vector<T> & v){
	for(auto & i : v) is >> i;
	return is;
}

using llt = long long;
using vi = vector<int>;
using vll = vector<llt>;

int N;
vi A;
vi Flag;

void proc(){
    vi pos;
    Flag.assign(N + 1, 0);
    for(int i=1;i<=N;++i){
        if(1 <= A[i] and A[i] <= N and Flag[A[i]] == 0){
            Flag[A[i]] = 1;
        }else{
            pos.emplace_back(i);
        }
    }    

    vi candi;
    for(int i=1;i<=N;++i)if(0==Flag[i])candi.emplace_back(i);

    cout << pos.size() << endl;
    for(int i=0;i<pos.size();++i){
        cout << pos[i] << " " << candi[i] << "\n";
    }     
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);   
    cin >> N;
    input(A, N);
    proc();
    return 0;
}